package com.ruyuan.eshop.common.service.trade.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ruyuan.eshop.common.mapper.OrderComplainCommunicationMapper;
import com.ruyuan.eshop.common.domain.entity.OrderComplainCommunicationDO;
import com.ruyuan.eshop.common.service.trade.OrderComplainCommunicationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 交易投诉对话表业务类
 */
@Service
public class OrderComplainCommunicationServiceImpl implements OrderComplainCommunicationService {

	@Autowired
	private OrderComplainCommunicationMapper orderComplainCommunicationMapper;


	/**
	 * 查询交易投诉对话表列表
	 *
	 * @param complainId   交易投诉id
	 * @return 交易投诉对话表列表
	 */
	@Override
	public List<OrderComplainCommunicationDO> list(long complainId) {

		return this.orderComplainCommunicationMapper.selectList(new QueryWrapper<OrderComplainCommunicationDO>()
				.eq("complain_id",complainId)
				.orderByAsc("create_time"));
	}

	/**
	 * 添加交易投诉对话表
	 *
	 * @param orderComplainCommunicationDO 交易投诉对话表
	 * @return OrderComplainCommunication 交易投诉对话表
	 */
	@Override
	@Transactional(rollbackFor=Exception.class)
	public OrderComplainCommunicationDO add(OrderComplainCommunicationDO orderComplainCommunicationDO)	{
		this.orderComplainCommunicationMapper.insert(orderComplainCommunicationDO);

		return orderComplainCommunicationDO;
	}

}
